﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for ThanhVienDAL
/// </summary>
public class ThanhVienController
{
    public ThanhVienController()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    ThanhVienDAL DAL = new ThanhVienDAL();
    public DataTable fnC_GetDataThanhVien(ThanhVienEntity ThanhVien)
    {
        return DAL.fnG_GetDataThanhVien(ThanhVien);
    }
    public int fnC_UpdateMatKhau(ThanhVienEntity ThanhVien)
    {
        return DAL.fnG_UpdateMatKhau(ThanhVien);
    }
    /// <summary>
    /// Update thông tin admin
    /// </summary>
    /// <param name="sInput"></param>
    /// <returns></returns>
    public int fnC_UpdateThongTinTV(ThanhVienEntity ThanhVien)
    {
        return DAL.fnG_UpdateThongTinTV(ThanhVien);
    }
    /// <summary>
    /// Hàm Mã Hóa Chuỗi
    /// </summary>
    /// <param name="sInput">Chuỗi Cần Mã Hóa</param>
    /// <returns>Chuỗi Mã Hóa MD5</returns>
    public string MD5(string sInput)
    {
        byte[] pass = System.Text.Encoding.UTF8.GetBytes(sInput);
        System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
        // lấy mảng byte đã mã hóa theo MD5
        byte[] hash = md5.ComputeHash(pass);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        // chuyển thành chuỗi ký tự
        for (int i = 0; i < hash.Length; i++)
            sb.Append(hash[i].ToString("X2"));
        // trả về chuỗi ký tự đã mã hóa	
        return sb.ToString();

    }
}